import { IHotSong } from "../actions/hotsongs.action";
import {
  GetSongdetailUnionType,
  GET_SONG_DETAIL_SUCCESS,
} from "../actions/songdetail.action";

const initialState: IHotSong | {} = {};

export default function songDetailReducer(
  state = initialState,
  action: GetSongdetailUnionType
) {
  switch (action.type) {
    case GET_SONG_DETAIL_SUCCESS:
      if (action.payload.songs.length > 0) {
        return action.payload.songs[0];
      } else {
        return state;
      }
    default:
      return state;
  }
}
